###############################################################################
# SuperLinks                                                                  #
# Copyright (c) 2000-2007 Greg Nolle (http://greg.nolle.co.uk)                #
###############################################################################
# This program is free software; you can redistribute it and/or modify it     #
# under the terms of the GNU General Public License as published by the Free  #
# Software Foundation; either version 2 of the License, or (at your option)   #
# any later version.                                                          #
#                                                                             #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   #
# more details.                                                               ##                                                                             #
# You should have received a copy of the GNU General Public License along     #
# with this program; if not, write to the Free Software Foundation, Inc.,     #
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                 #
###############################################################################
# ControlPanel/Output/GeneralOptions.pm.pl -> GeneralOptions module           #
###############################################################################
# DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!                         #
###############################################################################
package Skin::CP::GeneralOptions;

BEGIN { require "System.pm.pl"; import System qw($SYSTEM); }
BEGIN { require "General.pm.pl"; import General qw($GENERAL); }
require "Standard.pm.pl";

use HTML::Dialog;
use HTML::Form;
use strict;

sub new {
  my ($class) = @_;
  my $self    = {};
  return bless ($self, $class);
}

sub DESTROY { }

###############################################################################
# show subroutine
sub show {
  my $self = shift;
  my %in = (input => undef, error => "", @_);

  my $Dialog = HTML::Dialog->new();
  my $Form   = HTML::Form->new();

  my @Sections = (
    { title => "General Information", items => [
      { type => "row", item => { body => "Please fill out all the required (<font color=\"Red\"><b>*</b></font>) fields:", colspan => "2" } },
      { type => "textbox", item => { name => "SITE_TITLE", subject => "Web Site Name", required => 1, iconhelp => "The title of your web site." } },
      { type => "textbox", item => { name => "SITE_URL", subject => "Web Site URL", required => 1, iconhelp => "The full URL of your web site." } },
      { type => "textbox", item => { name => "LINKS_TITLE", subject => "Links Name", required => 1, iconhelp => "The title of your SuperLinks system." } },
      { type => "textbox", item => { name => "LINKS_DESCRIPTION", subject => "Links Description", required => 1, iconhelp => "The description or catch-phrase of your SuperLinks sytem (appears at the top of every page)." } },
      { type => "textbox", item => { name => "CONTACT_EMAIL", subject => "Contact Email", required => 1, iconhelp => "The email address you want used in emails sent by SuperLinks." } },
      { type => "textbox", item => { name => "ADMIN_EMAIL", subject => "Admin Email", required => 1, iconhelp => "The email address you want add/modify notification messages sent to." } }
    ]},
    { title => "Mail Options", items => [
      { type => "radio", item => { name => "MAIL_FUNCTIONS", subject => "Mail Functions", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable email functions, such as notification of additions, modifications, etc. Individual functions can be enabled/disabled below." } },
      { type => "radio", item => { name => "NOTIFY_ADMIN_OF_ADD", subject => "Notify Admin of Additions", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable notification of resource additions to the administrator." } },
      { type => "radio", item => { name => "NOTIFY_ADMIN_OF_MOD", subject => "Notify Admin of Modifications", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable notification of resource modifications to the administrator." } },
      { type => "radio", item => { name => "NOTIFY_ADMIN_OF_DEAD_LINK", subject => "Notify Admin of Dead Links", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable notification of resources being marked as dead to the administrator." } },
      { type => "radio", item => { name => "NOTIFY_ADMIN_OF_REMOVE", subject => "Notify Admin of Removals", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable notification of resource removals to the administrator." } },
      { type => "radio", item => { name => "NOTIFY_USER_OF_ADD", subject => "Notify User of Additions", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable emails sent to users after they add a resource." } },
      { type => "radio", item => { name => "NOTIFY_USER_OF_MOD", subject => "Notify User of Modifications", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable emails sent to users after they modify a resource." } },
      { type => "radio", item => { name => "HTML_IN_ADMIN_EMAILS", subject => "HTML in Emails to Admin", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable HTML in emails sent to the administrator." } },
      { type => "radio", item => { name => "HTML_IN_USER_EMAILS", subject => "HTML in Emails to User", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable HTML in emails sent to users." } }
    ]},
    { title => "Date & Time Options", items => [
      { type => "radio", item => { name => "DATE_FORMAT", subject => "Date Format", required => 1, items => [{ value => "US", label => "US Format (MM-DD-YYYY)"}, { value => "USE", label => "Expanded US Format (Month DD, YYYY)" }, { value => "EU", label => "European Format (DD-MM-YYYY)" }, { value => "EUE", label => "Expanded European Format (DD Month, YYYY)" }], join => "<br>", iconhelp => "The format dates should appear in." } },
      { type => "radio", item => { name => "TIME_FORMAT", subject => "Time Format", required => 1, items => [{ value => "24", label => "24 Hour Time Format" }, { value => "12", label => "AM/PM 12 Hour Time Format" }], join => "<br>", iconhelp => "The format times should appear in." } }
    ]},
    { title => "New, Hot & Cool Resources", items => [
      { type => "textbox", item => { name => "NEW1_CUTOFF", subject => "New 1 Status Cut-off", help => "days", required => 1, iconhelp => "A resource has New 1 status when it's age is between the 'New 1 Status Cut-off' and the 'New 2 Status Cut-off'." } },
      { type => "textbox", item => { name => "NEW2_CUTOFF", subject => "New 2 Status Cut-off", help => "days", required => 1, iconhelp => "A resource has New 2 status when it's age is between the 'New 2 Status Cut-off' and the 'New 3 Status Cut-off'." } },
      { type => "textbox", item => { name => "NEW3_CUTOFF", subject => "New 3 Status Cut-off", help => "days", required => 1, iconhelp => "A resource has New 3 status when it's age is less than the 'New 3 Status Cut-off'." } },
      { type => "textbox", item => { name => "HOT1_CUTOFF", subject => "Hot 1 Status Cut-off", help => "hits", required => 1, iconhelp => "A resource has Hot 1 status when the number of hits is between the 'Hot 1 Status Cut-off' and the 'Hot 2 Status Cut-off'." } },
      { type => "textbox", item => { name => "HOT2_CUTOFF", subject => "Hot 2 Status Cut-off", help => "hits", required => 1, iconhelp => "A resource has Hot 2 status when the number of hits is between the 'Hot 2 Status Cut-off' and the 'Hot 3 Status Cut-off'." } },
      { type => "textbox", item => { name => "HOT3_CUTOFF", subject => "Hot 3 Status Cut-off", help => "hits", required => 1, iconhelp => "A resource has Hot 3 status when the number of hits is above the 'Hot 3 Status Cut-off'." } },
      { type => "textbox", item => { name => "COOL1_CUTOFF", subject => "Cool 1 Status Cut-off", help => "(rating)", required => 1, iconhelp => "A resource has Cool 1 status when the rating is between the 'Cool 1 Status Cut-off' and the 'Cool 2 Status Cut-off'." } },
      { type => "textbox", item => { name => "COOL2_CUTOFF", subject => "Cool 2 Status Cut-off", help => "(rating)", required => 1, iconhelp => "A resource has Cool 2 status when the rating is between the 'Cool 2 Status Cut-off' and the 'Cool 3 Status Cut-off'." } },
      { type => "textbox", item => { name => "COOL3_CUTOFF", subject => "Cool 3 Status Cut-off", help => "(rating)", required => 1, iconhelp => "A resource has Cool 3 status when the rating is above the 'Cool 3 Status Cut-off'" } }
    ]},
    { title => "What's New, What's Hot & What's Cool Pages", items => [
      { type => "textbox", item => { name => "WHAT_NEW_CUTOFF", subject => "What's New Cut-off", help => "days", required => 1, iconhelp => "A resource will appear in the What's New page if its age is less than 'What's New Cut-off'." } },
      { type => "textbox", item => { name => "WHAT_NEW_NUMBER", subject => "What's New Max Qty", help => "&nbsp;", required => 1, iconhelp => "The maximum number of resources to show in the What's New page." } },
      { type => "selectbox", item => { name => "WHAT_NEW_SORT_FIELD", subject => "What's New Sort Field", help => "&nbsp;", required => 1, items => [{ value => "ID", label => "ID" }, { value => "TITLE", label => "Title" }, { value => "DESCRIPTION", label => "Description" }, { value => "KEYWORDS", label => "Keywords" }, { value => "CONTACT_NAME", label => "Contact Name" }, { value => "HITS", label => "Hits" }, { value => "CREATE_SECOND", label => "Creation Date" }, { value => "UPDATE_SECOND", label => "Updated Date" }, { value => "RATING", label => "Rating" }], iconhelp => "Sort the What's New page listings by this field." } },
      { type => "radio", item => { name => "WHAT_NEW_SORT_BY", subject => "What's New Sort Order", required => 1, items => [{ value => "A-Z", label => "Ascending" }, { value => "Z-A", label => "Descending" }], join => "&nbsp;", iconhelp => "Sort the What's New page listings in this order." } },
      { type => "textbox", item => { name => "WHAT_HOT_CUTOFF", subject => "What's Hot Cut-off", help => "hits", required => 1, iconhelp => "A resource will appear in the What's Hot page if the number of hits is more than 'What's Hot Cut-off'." } },
      { type => "textbox", item => { name => "WHAT_HOT_NUMBER", subject => "What's Hot Max Qty", help => "&nbsp;", required => 1, iconhelp => "The maximum number of resources to show in the What's Hot page." } },
      { type => "selectbox", item => { name => "WHAT_HOT_SORT_FIELD", subject => "What's Hot Sort Field", help => "&nbsp;", required => 1, items => [{ value => "ID", label => "ID" }, { value => "TITLE", label => "Title" }, { value => "DESCRIPTION", label => "Description" }, { value => "KEYWORDS", label => "Keywords" }, { value => "CONTACT_NAME", label => "Contact Name" }, { value => "HITS", label => "Hits" }, { value => "CREATE_SECOND", label => "Creation Date" }, { value => "UPDATE_SECOND", label => "Updated Date" }, { value => "RATING", label => "Rating" }], iconhelp => "Sort the What's Hot page listings by this field." } },
      { type => "radio", item => { name => "WHAT_HOT_SORT_BY", subject => "What's Hot Sort Order", required => 1, items => [{ value => "A-Z", label => "Ascending" }, { value => "Z-A", label => "Descending" }], join => "&nbsp;", iconhelp => "Sort the What's Hot page listings in this order." } },
      { type => "textbox", item => { name => "WHAT_COOL_CUTOFF", subject => "What's Cool Cut-off", help => "(rating)", required => 1, iconhelp => "A resource will appear in the What's Cool page if the rating is more than 'What's Cool Cut-off'." } },
      { type => "textbox", item => { name => "WHAT_COOL_NUMBER", subject => "What's Cool Max Qty", help => "&nbsp;", required => 1, iconhelp => "The maximum number of resources to show in the What's Cool page." } },
      { type => "selectbox", item => { name => "WHAT_COOL_SORT_FIELD", subject => "What's Cool Sort Field", help => "&nbsp;", required => 1, items => [{ value => "ID", label => "ID" }, { value => "TITLE", label => "Title" }, { value => "DESCRIPTION", label => "Description" }, { value => "KEYWORDS", label => "Keywords" }, { value => "CONTACT_NAME", label => "Contact Name" }, { value => "HITS", label => "Hits" }, { value => "CREATE_SECOND", label => "Creation Date" }, { value => "UPDATE_SECOND", label => "Updated Date" }, { value => "RATING", label => "Rating" }], iconhelp => "Sort the What's Cool page listings by this field." } },
      { type => "radio", item => { name => "WHAT_COOL_SORT_BY", subject => "What's Cool Sort Order", required => 1, items => [{ value => "A-Z", label => "Ascending" }, { value => "Z-A", label => "Descending" }], join => "&nbsp;", iconhelp => "Sort the What's Cool page listings in this order." } }
    ]},
    { title => "Category Pages", items => [
      { type => "selectbox", item => { name => "CATEGORY_DEFAULT_SORT", subject => "Default Sort Field", required => 1, items => [{ value => "ID", label => "ID" }, { value => "TITLE", label => "Title" }, { value => "DESCRIPTION", label => "Description" }, { value => "KEYWORDS", label => "Keywords" }, { value => "CONTACT_NAME", label => "Contact Name" }, { value => "HITS", label => "Hits" }, { value => "CREATE_SECOND", label => "Creation Date" }, { value => "UPDATE_SECOND", label => "Updated Date" }], iconhelp => "Sort the category listings by this field." } },
      { type => "radio", item => { name => "CATEGORY_DEFAULT_BY", subject => "Default Sort Order", required => 1, items => [{ value => "A-Z", label => "Ascending" }, { value => "Z-A", label => "Descending" }], join => "&nbsp;", iconhelp => "Sort the category listings in this order." } },
      { type => "textbox", item => { name => "CATEGORY_DEFAULT_PERPAGE", subject => "Default Number of Resources per Page", required => 1, iconhelp => "The maximum number of resources to show on a category listings page. If there are more than this number in a category then the resources will be spanned across multiple pages." } },
    ]},
    { title => "Search", items => [
      { type => "selectbox", item => { name => "SEARCH_DEFAULT_FIELDS", subject => "Default Fields", required => 1, multiple => 1, rows => 3, items => [{ value => "TITLE", label => "Title" }, { value => "DESCRIPTION", label => "Description" }, { value => "KEYWORDS", label => "Keywords" }], iconhelp => "The default fields that searchs will be performed on." } },
      { type => "textbox", item => { name => "SEARCH_DEFAULT_PERPAGE", subject => "Default Number of Resources Per Page", required => 1, iconhelp => "Default number of resources to display in a page of search results." } },
      { type => "radio", item => { name => "SEARCH_DEFAULT_CASE", subject => "Default Case", required => 1, items => [{ value => "1", label => "Sensitive" }, { value => "0", label => "Insensitive" }], join => "&nbsp;", iconhelp => "Use sensitive/insensitive searchs by default." } },
      { type => "checkbox", item => { name => "SEARCH_DEFAULT_WHOLE", items => [{ value => "1", label => "Match whole words only by default?" }], iconhelp => "Match only whole words by default when performing searchs." } }
    ]},
    { title => "Filtering", items => [
      { type => "textarea", item => { name => "BAN_IPS", value => join("|", @{ $GENERAL->{'BAN_IPS'} }), subject => "Banned IP Addresses", rows => 3, sub_field => $Form->TextBox(name => "ITEM_BAN_IPS", class => "")." ".$Form->Button(items => [{ type => "button", value => "Add", extra => { onClick => "ArrayBoxAdd(form.ITEM_BAN_IPS, form.FORM_BAN_IPS);" } }]), iconhelp => "IP addresses to ban from adding or modifying resources." } },
      { type => "textarea", item => { name => "BAN_URLS", value => join("|", @{ $GENERAL->{'BAN_URLS'} }), subject => "Banned URLs", rows => 3, sub_field => $Form->TextBox(name => "ITEM_BAN_URLS", class => "")." ".$Form->Button(items => [{ type => "button", value => "Add", extra => { onClick => "ArrayBoxAdd(form.ITEM_BAN_URLS, form.FORM_BAN_URLS);" } }]), iconhelp => "URLs to ban from being added to the database. These can be partial URLs." } },
      { type => "textarea", item => { name => "BAN_WORDS", value => join("|", @{ $GENERAL->{'BAN_WORDS'} }), subject => "Banned Words", rows => 3, sub_field => $Form->TextBox(name => "ITEM_BAN_WORDS", class => "")." ".$Form->Button(items => [{ type => "button", value => "Add", extra => { onClick => "ArrayBoxAdd(form.ITEM_BAN_WORDS, form.FORM_BAN_WORDS);" } }]), iconhelp => "Words to censor in Description and Title fields." } },
      { type => "radio", item => { name => "HTML_IN_REVIEWS", subject => "Allow HTML in Reviews", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Allow users to use HTML tags in reviews. If disabled, HTML tags will be converted to text." } }
    ]},
    { title => "Field Sizes", items => [
      { type => "textbox", item => { name => "SIZE_TITLE", subject => "Resource Title", required => 1, iconhelp => "Maximum number of characters for a resource's title." } },
      { type => "textbox", item => { name => "SIZE_DESCRIPTION", subject => "Resource Description", required => 1, iconhelp => "Maximum number of characters for a resource's description." } },
      { type => "textbox", item => { name => "SIZE_KEYWORDS", subject => "Resource Keywords", required => 1, iconhelp => "Maximum number of characters for a resource's keywords." } }
    ]},
    { title => "Resource Images", items => [
      { type => "radio", item => { name => "IMAGE_UPLOAD", subject => "User Uploading", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Allow users to upload images for their resources." } },
      { type => "radio", item => { name => "IMAGE_URL", subject => "Remote Images", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Allow users to specify an external URL for the images for their resources." } },
      { type => "textbox", item => { name => "UPLOAD_MAXSIZE", subject => "Max. Upload Size (KB)", iconhelp => "Maximum size, in kilobytes, for user-uploaded images. Leave this field blank if you don't want to sizes to be checked (not recommended)." } },
      { type => "textbox", item => { name => "UPLOAD_MAXWIDTH", subject => "Max. Picture Width (px)", iconhelp => "Maximum width, in pixels, for user-uploaded images. Leave this field blank if you don't want image widths to be checked." } },
      { type => "textbox", item => { name => "UPLOAD_MAXHEIGHT", subject => "Max. Picture Height (px)", iconhelp => "Maximum height, in pixels, for user-uploaded images. Leave this field blank if you don't want image heights to be checked." } },
      { type => "textarea", item => { name => "UPLOAD_EXTENSIONS", value => join("|", @{ $GENERAL->{'UPLOAD_EXTENSIONS'} }), subject => "Upload File Extensions", rows => 3, sub_field => $Form->TextBox(name => "ITEM_UPLOAD_EXTENSIONS", class => "")." ".$Form->Button(items => [{ type => "button", value => "Add", extra => { onClick => "ArrayBoxAdd(form.ITEM_UPLOAD_EXTENSIONS, form.FORM_UPLOAD_EXTENSIONS);" } }]), iconhelp => "Allowed extensions for image uploads." } }
    ]},
    { title => "Duplicate URL Checking", items => [
      { type => "checkbox", item => { name => "CHECK_DUPLICATE_PROTOCOL", subject => "Criteria to Check", items => [{ value => "1", label => "Protocol (e.g. http, ftp, etc.)" }], iconhelp => "Select the criteria to use when checking a new URL to see if it's a duplicate." } },
      { type => "checkbox", item => { name => "CHECK_DUPLICATE_HOST", items => [{ value => "1", label => "Host (subdomain and domain, e.g. www.somewhere.com)" }] } },
      { type => "checkbox", item => { name => "CHECK_DUPLICATE_PORT", items => [{ value => "1", label => "Port (e.g. 80)" }] } },
      { type => "checkbox", item => { name => "CHECK_DUPLICATE_DIRECTORY", items => [{ value => "1", label => "Directory" }] } },
      { type => "checkbox", item => { name => "CHECK_DUPLICATE_FILENAME", items => [{ value => "1", label => "Filename (without extension)" }] } },
      { type => "checkbox", item => { name => "CHECK_DUPLICATE_EXTENSION", items => [{ value => "1", label => "File Extension" }] } },
      { type => "checkbox", item => { name => "CHECK_DUPLICATE_QUERY", items => [{ value => "1", label => "Query String (e.g. ?action=Something)" }] } },
      { type => "radio", item => { name => "CHECK_DUPLICATE_ACTION", subject => "Action", items => [{ value => "WARN", label => "Do not accept submission and warn user to change URL" }, { value => "FLAG", label => "Accept submission but flag resource" }], join => "<br>", iconhelp => "Choose what action to take when someone tries to use a duplicate URL." } }
    ]},
    { title => "Random Link", items => [
      { type => "textbox", item => { name => "RANDOM_MIN_HITS", subject => "Minimum Hits", iconhelp => "The minimum number of hits a resource must have before it has a chance of being picked as a random link." } },
      { type => "textbox", item => { name => "RANDOM_MIN_RATING", subject => "Minimum Rating", iconhelp => "The minimum rating a resource must have before it has a chance of being picked as a random link." } },
      { type => "selectbox", item => { name => "RANDOM_CATEGORIES", subject => "Categories", multiple => 1, rows => 4, items => [&Standard::MapArray({ value => "\${ID}", label => "\${FULL_TITLE}" }, $in{'input'}->{'CATEGORIES'})], iconhelp => "The categories from which random links will be chosen." } }
    ]},
    { title => "Featured Link", items => [
      { type => "radio", item => { name => "FEATURED", subject => "Enable/Disable", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable the Featured Link feature." } },
      { type => "textbox", item => { name => "FEATURED_MIN_HITS", subject => "Minimum Hits", iconhelp => "The minimum number of hits a resource must have before it has a chance of being picked as a featured link." } },
      { type => "textbox", item => { name => "FEATURED_MIN_RATING", subject => "Minimum Rating", iconhelp => "The minimum rating a resource must have before it has a chance of being picked as a featured link." } },
      { type => "selectbox", item => { name => "FEATURED_CATEGORIES", subject => "Categories", multiple => 1, rows => 4, items => [&Standard::MapArray({ value => "\${ID}", label => "\${FULL_TITLE}" }, $in{'input'}->{'CATEGORIES'})], iconhelp => "The categories from which featured links will be chosen." } }
    ]},
    { title => "Misc. Options", items => [
      { type => "selectbox", item => { name => "SKIN", subject => "Default Skin", required => 1, items => [&Standard::MapArray({ value => "\${ID}", label => "\${DESCRIPTION}" }, $in{'input'}->{'SKINS'})], iconhelp => "The default skin to use when displaying pages. This can be overided on a individual basis by appending ?Skin=xxx to a URL." } },
      { type => "radio", item => { name => "VALIDATE_NEW_RESOURCES", subject => "Validate New Resources", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable validation of new resources. When enabled, new resources must be validated by an administrator before they will appear in the listings." } },
      { type => "radio", item => { name => "VALIDATE_MOD_RESOURCES", subject => "Validate Modified Resources", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable validation of modified resources. When enabled, modified resources must be validated by an administrator before they will re-aappear in the listings." } },
      { type => "radio", item => { name => "VALIDATE_REM_RESOURCES", subject => "Validate Removed Resources", required => 1, items => [{ value => "1", label => "Enable" }, { value => "0", label => "Disable" }], join => "&nbsp;", iconhelp => "Enable/disable validation of deleted resources. When enabled, removed resources must be validated by an administrator before they are permanently removed from the database." } },
      { type => "selectbox", item => $self->myExtraCategoryFields() },
      { type => "divider", item => { colspan => 2 } },
      { type => "button", item => { items => [{ type => "submit", value => "Modify" }, { type => "reset", value => "Cancel" }], join => "&nbsp;" } }
    ]}
  );

  my $LANGUAGE = {
    "MISSING" => { },
    "ERROR"   => qq~<p><font class="error">There were errors:<ul>[%error%]</ul></font>~
  };
  
  foreach my $section (@Sections) {
    foreach my $item (@{ $section->{'items'} }) {
      $LANGUAGE->{'MISSING'}->{ $item->{'item'}->{'name'} } = qq~<li>You didn't fill in the "$item->{'item'}->{'subject'}" field.~ if ($item->{'item'}->{'subject'});
    }
  }
  
  $in{'error'} = &Standard::ProcessError(LANGUAGE => $LANGUAGE, ERROR => $in{'error'});
  $Sections[0]->{'items'}->[0]->{'item'}->{'body'} .= $in{'error'};

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  my $Body;
  foreach my $section (@Sections) {
    $Body .= $Dialog->TableHeader(titles => [{ title => $section->{'title'}, colspan => 2, align => "left" }]) if ($section->{'title'});
    
    foreach my $item (@{ $section->{'items'} }) {
      if ($item->{'type'} eq "textbox") {
        $item->{'item'}->{'value'} = $GENERAL->{ $item->{'item'}->{'name'} } unless (defined($item->{'item'}->{'value'}));
        $item->{'item'}->{'name'}  = "FORM_".$item->{'item'}->{'name'};
        $item->{'item'}->{'name'}  = "" if ($item->{'item'}->{'locked'});
        $Body .= $Dialog->FormTextBox(%{ $item->{'item'} });
      } elsif ($item->{'type'} eq "textarea") {
        $item->{'item'}->{'value'} = $GENERAL->{ $item->{'item'}->{'name'} } unless (defined($item->{'item'}->{'value'}));
        $item->{'item'}->{'name'}  = "FORM_".$item->{'item'}->{'name'};
        $item->{'item'}->{'name'}  = "" if ($item->{'item'}->{'locked'});
        $Body .= $Dialog->FormTextArea(%{ $item->{'item'} });
      } elsif ($item->{'type'} eq "radio") {
        $item->{'item'}->{'value'} = $GENERAL->{ $item->{'item'}->{'name'} } unless (defined($item->{'item'}->{'value'}));
        $item->{'item'}->{'name'}  = "FORM_".$item->{'item'}->{'name'};
        $item->{'item'}->{'name'}  = "" if ($item->{'item'}->{'locked'});
        $Body .= $Dialog->FormRadio(%{ $item->{'item'} });
      } elsif ($item->{'type'} eq "checkbox") {
        $item->{'item'}->{'value'} = $GENERAL->{ $item->{'item'}->{'name'} } unless (defined($item->{'item'}->{'value'}));
        $item->{'item'}->{'name'}  = "FORM_".$item->{'item'}->{'name'};
        $item->{'item'}->{'name'}  = "" if ($item->{'item'}->{'locked'});
        $Body .= $Dialog->FormCheckBox(%{ $item->{'item'} });
      } elsif ($item->{'type'} eq "selectbox") {
        $item->{'item'}->{'value'} = $GENERAL->{ $item->{'item'}->{'name'} } unless (defined($item->{'item'}->{'value'}));
        $item->{'item'}->{'name'} = "FORM_".$item->{'item'}->{'name'};
        $item->{'item'}->{'name'}  = "" if ($item->{'item'}->{'locked'});
        $Body .= $Dialog->FormSelectBox(%{ $item->{'item'} });
      } elsif ($item->{'type'} eq "row") {
        $Body .= $Dialog->TableRow(items => [$item->{'item'}]);
      } elsif ($item->{'type'} eq "button") {
        $Body .= $Dialog->FormButton(%{ $item->{'item'} });        
      } elsif ($item->{'type'} eq "divider") {
        $Body .= $Dialog->TableDivider(%{ $item->{'item'} });
      }
    }
  }
  
  $Body = $Dialog->Table(body => $Body);
  $Body = $Dialog->StandardPage(
    body        => $Body,
    header      => "General Options",
    head_extra  => "<script src=\"$SYSTEM->{'PUBLIC_URL'}/functions.js\"></script>",
    form        => 1,
    form_extra  => { onSubmit => "DblArraySubmit(form.FORM_CATEGORY_EXTRA);" },
    hiddens     => [
      { name => "action", value => "DoGeneralOptions" },
      { name => "CP", value => "1" },
      { name => "SID", value => $SL::ADMIN{'SID'} }
    ]
  );

  return $Body;
}

###############################################################################
# do subroutine
sub do {
  my $self = shift;

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  my $Dialog = HTML::Dialog->new();

  return $Dialog->StandardPage(
    body    => qq~The general options have been updated.<p>Click <a href="$SYSTEM->{'SCRIPT_URL'}?CP=1&action=Summary&SID=$SL::ADMIN{'SID'}">here</a> if you're not redirected in 5 seconds.~,
    header  => "General Options",
    metas   => [
      { http_equiv => "refresh", content => "5; url=$SYSTEM->{'SCRIPT_URL'}?CP=1&action=Summary&SID=$SL::ADMIN{'SID'}" }
    ]
  );
}

###############################################################################
# myExtraCategoryFields subroutine
sub myExtraCategoryFields {
  my $self = shift;

  my $Form = HTML::Form->new();

  my @options;
  if (my @values = $SL::CGI->param('FORM_CATEGORY_EXTRA')) {
    foreach my $value (@values) {
      my ($id, $description) = split(/\|\^\|/, $value);
      push(@options, { value => $value, label => "\"$id\" => \"$description\"" });
    }
  } else {
    foreach my $value (@{ $GENERAL->{'CATEGORY_EXTRA'} }) {
      push(@options, { value => $value->{'ID'}."|^|".$value->{'DESCRIPTION'}, label => "\"$value->{'ID'}\" => \"$value->{'DESCRIPTION'}\"" });
    }
  }

  my $SubField = "ID: ".$Form->TextBox(
    name      => "ID_CATEGORY_EXTRA",
    class     => "",
    empty     => 1
  );
  $SubField .= " Description: ".$Form->TextBox(
    name      => "DESCRIPTION_CATEGORY_EXTRA",
    class     => "",
    empty     => 1
  );
  $SubField .= " ".$Form->Button(
    items     => [
      { type => "button", name => "ADD_CATEGORY_EXTRA", value => "Add", extra => { onClick => "DblArrayAdd(form.ID_CATEGORY_EXTRA, form.DESCRIPTION_CATEGORY_EXTRA, form.FORM_CATEGORY_EXTRA);" } },
      { type => "button", name => "EDIT_CATEGORY_EXTRA", value => "Edit", extra => { disabled => "", onClick => "DblArrayEdit(form.ID_CATEGORY_EXTRA, form.DESCRIPTION_CATEGORY_EXTRA, form.FORM_CATEGORY_EXTRA, form.EDIT_CATEGORY_EXTRA, form.DEL_CATEGORY_EXTRA);" } },
      { type => "button", name => "DEL_CATEGORY_EXTRA", value => "Delete", extra => { disabled => "", onClick => "DblArrayDelete(form.ID_CATEGORY_EXTRA, form.DESCRIPTION_CATEGORY_EXTRA, form.FORM_CATEGORY_EXTRA, form.EDIT_CATEGORY_EXTRA, form.DEL_CATEGORY_EXTRA);" } }
    ], join => "&nbsp;"
  );
  
  return {
    name      => "CATEGORY_EXTRA",
    subject   => "Extra Category Fields",
    multiple  => 1,
    rows      => 4,
    items     => \@options,
    extra     => { onChange => "DblArrayChange(form.FORM_CATEGORY_EXTRA, form.EDIT_CATEGORY_EXTRA, form.DEL_CATEGORY_EXTRA);" },
    sub_field => $SubField,
    iconhelp  => "Define additional fields for categories."
  };
}

1;